package com.sopra.tecnica.poc.server.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import com.sopra.tecnica.poc.server.entity.SizeEntity;
import com.sopra.tecnica.poc.server.service.SizeService;

@Controller
@RequestMapping("size")
public class SizeController {
	
	@Autowired
	private SizeService sizeService;
	
	@RequestMapping("item")
	public void findItemSizes(@RequestParam("order") String orderNum,
			@RequestParam("line") String lineNum,
			Model model) {
		List<SizeEntity> result = sizeService.findItemSizes(orderNum, lineNum);
		model.addAttribute(result);
	}
	
	@RequestMapping("update")
	public void updateSize(@RequestParam("order") Integer orderNum,
			@RequestParam("line") Integer lineNum,
			@RequestParam("sizeId") Integer sizeId,
			@RequestParam("qty") Integer qty,
			@RequestParam("discount") Integer discount,
			@RequestParam("netPrice") Integer netPrice) {
		sizeService.update(orderNum, lineNum, sizeId, qty, discount, netPrice);
	}
}
